package com.xxx.modules.controller;;
import com.xxx.modules.service.VacateService;
import com.xxx.modules.entity.Vacate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * vacate
 *
 * @author 北易航
 * @since 1.0.0 2022-12-28
 */
@RestController
@RequestMapping("/common/vacate")
@Api(tags="vacate")
public class VacateController {
    @Autowired
    private VacateService vacateService;

    /**
    *  获取所有请假信息
    * @param pageNum
    * @param pageSize
    * @param vacate
    * @return
    */

    @GetMapping("/getVacateInfo")
    @ApiOperation("获取所有请假信息")
    public Result getVacateInfo(Vacate vacate, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Vacate> data = vacateService.selectVacateInfo(vacate,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存请假信息
    * @param vacate
    * @return
    */
    @PostMapping("/saveVacateInfo")
    @ApiOperation("保存请假信息")
    public Result saveVacateInfo(@RequestBody Vacate vacate){
        vacateService.saveVacateInfo(vacate);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新请假信息
     * @param vacate
     * @return
     */

    @PutMapping("/updateVacateInfo")
    @ApiOperation("更新请假信息")
    public Result updateVacateInfo(@RequestBody Vacate vacate){
        vacateService.updateVacateInfo(vacate);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除请假信息
     * @param id
     * @return
     */
    @DeleteMapping("/delVacateInfo")
    @ApiOperation("根据id删除请假信息")
    public Result delVacateInfo(Integer id){
        vacateService.delVacateInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合批量删除请假信息
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchVacateInfo")
    @ApiOperation("根据id集合批量删除请假信息")
    public Result delBatchVacateInfo(String idList){
        vacateService.delBatchVacateInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}